package com.zy.design.pattern.template.jdbctm;

import com.zy.design.pattern.template.original.User;
import org.apache.commons.compress.utils.Lists;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

/**
 * @author zhaoyi
 * @date 2021/7/28 11:44
 */
public class UserMapper implements Mapper<User> {
    @Override
    public List<User> convert(ResultSet rs) {
        List<User> list = Lists.newArrayList();
        try {
            while (rs.next()) {
                User user = new User();
                user.setId(rs.getInt("id"));
                user.setTitle(rs.getString("title"));
                list.add(user);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return list;
    }
}
